package com.wzcl.app.dao.repository;

import com.wzcl.app.dao.model.Attribute;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

public interface AttributeRepository extends JpaRepository<Attribute,Integer>, JpaSpecificationExecutor<Attribute> {


    @Query(value = "SELECT m FROM Attribute m WHERE m.name = ?1 and m.parentId IS NULL")
    Attribute findParentByName(String name);

    @Query(value = "SELECT m FROM Attribute m WHERE m.name = ?1 and m.parentId = ?2 ")
    Attribute findByNameAndParentId(String name, Integer parentId);

}
